const mongoose = require('mongoose');
const Schema = mongoose.Schema;

const nutritionSuggestionSchema = new Schema(
  {
    userId: {
      type: Schema.Types.ObjectId,
      ref: 'User',
      required: true,
      index: true,
    },
    type: {
      type: String,
      required: true,
      enum: ['营养均衡', '热量控制', '蛋白质补充', '碳水适当', '脂肪控制', '膳食纤维', '维生素补充', '钠摄入控制', '其他'],
      index: true,
    },
    content: {
      type: String,
      required: true,
      trim: true,
    },
    relevantFoods: [
      {
        foodId: {
          type: Schema.Types.ObjectId,
          ref: 'Food',
          required: true,
        },
        reason: {
          type: String,
          required: true,
          trim: true,
        },
      },
    ],
    isRead: {
      type: Boolean,
      default: false,
      index: true,
    },
    isDeleted: {
      type: Boolean,
      default: false,
      index: true,
    }
  },
  {
    timestamps: true,
    collection: 'nutrition_suggestions'
  }
);

/**
 * @typedef NutritionSuggestion
 */
const NutritionSuggestion = mongoose.model('NutritionSuggestion', nutritionSuggestionSchema);

module.exports = NutritionSuggestion; 